Skip to content

feat(mcp): chart formatting options across all supported chart types#39887

Draft
msyavuz wants to merge 2 commits intomasterfrom
feat/mcp-chart-color-scheme
Draft

feat(mcp): chart formatting options across all supported chart types#39887
msyavuz wants to merge 2 commits intomasterfrom
feat/mcp-chart-color-scheme

Conversation

@msyavuz
Copy link
Copy Markdown
Member

@msyavuz msyavuz commented May 5, 2026

SUMMARY

Extends MCP-generated charts to expose Superset's native formatting controls across every chart type MCP currently supports.

Per chart, only fields the Superset viz actually consumes:

Chart Added
XY (line/bar/area/scatter) currency_format, show_value (data labels), x_axis_time_format
Pie currency_format, date_format, legend_orientation
PivotTable currency_format, date_format
MixedTimeseries color_scheme, currency_format(+_secondary), legend_orientation, show_value
BigNumber color_scheme, currency_format, time_format (trendline)
Table color_scheme

(color_scheme, AxisConfig.title/format, and LegendConfig already existed for XY+Pie from the prior commit.) Handlebars is skipped — its rendering is fully template-driven.

CurrencyFormat is a new shared pydantic model accepting {symbol, symbol_position} (with symbolPosition alias) so LLM clients can pass structured currency input. Per-column formatting on Table is out of scope and stays a follow-up — Superset exposes it via column_config, which doesn't fit a single chart-level field.

Drive-by fix: add_legend_config was writing legend_orientation to form_data, but the echarts plugins read legendOrientation. The wrong key was inert; chart now respects the user's choice.

Example:

{
  "dataset_id": 1,
  "config": {
    "chart_type": "xy",
    "x": {"name": "ds"}, "y": [{"name": "val", "aggregate": "SUM"}],
    "kind": "bar",
    "currency_format": {"symbol": "USD", "symbol_position": "prefix"},
    "show_value": true,
    "x_axis_time_format": "%Y-%m-%d"
  }
}

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

N/A — backend-only.

TESTING INSTRUCTIONS

  1. pytest tests/unit_tests/mcp_service/chart/test_chart_utils.py tests/unit_tests/mcp_service/chart/test_new_chart_types.py — 213 pass (38 new for formatting/CurrencyFormat).
  2. Via MCP generate_chart, pass any of the new fields (e.g. currency_format, show_value, legend_orientation) and confirm form_data carries them through to the rendered chart.

ADDITIONAL INFORMATION

  • Has associated issue: No
  • Required feature flags: No
  • Changes UI: No — backend MCP schema/mapper changes only
  • Includes DB Migration: No
  • Introduces new feature or API: Yes — new optional fields on existing MCP chart config schemas; new CurrencyFormat model
  • Removes existing feature or API: No

@codecov
Copy link
Copy Markdown

codecov Bot commented May 5, 2026

Codecov Report

❌ Patch coverage is 50.90909% with 27 lines in your changes missing coverage. Please review.
✅ Project coverage is 63.86%. Comparing base (d618837) to head (aaa7f27).
⚠️ Report is 33 commits behind head on master.

Files with missing lines Patch % Lines
superset/mcp_service/chart/chart_utils.py 10.34% 26 Missing ⚠️
superset/mcp_service/chart/schemas.py 96.15% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #39887      +/-   ##
==========================================
- Coverage   64.37%   63.86%   -0.51%     
==========================================
  Files        2569     2583      +14     
  Lines      134745   136743    +1998     
  Branches    31278    31522     +244     
==========================================
+ Hits        86737    87336     +599     
- Misses      46510    47891    +1381     
- Partials     1498     1516      +18     
Flag Coverage Δ
hive 39.38% <50.90%> (-0.30%) ⬇️
mysql 59.03% <50.90%> (-0.91%) ⬇️
postgres 59.11% <50.90%> (-0.91%) ⬇️
presto 41.08% <50.90%> (-0.35%) ⬇️
python 60.55% <50.90%> (-1.01%) ⬇️
sqlite 58.75% <50.90%> (-0.90%) ⬇️
unit 100.00% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Adds number/date/currency formatting, axis titles, data labels, legend
position, and color schemes across every chart type MCP currently
generates. Per-chart additions cover the formatting fields each
Superset visualization natively supports:

- XY: currency_format, show_value (data labels), x_axis_time_format
- Pie: currency_format, date_format, legend_orientation
- PivotTable: currency_format, date_format
- MixedTimeseries: color_scheme, currency_format(_secondary),
  legend_orientation, show_value
- BigNumber: color_scheme, currency_format, time_format (trendline)
- Table: color_scheme

CurrencyFormat model encapsulates {symbol, symbolPosition} so
callers can pass structured currency input. Also fixes the legend
orientation form_data key in add_legend_config (legendOrientation
is the canonical key consumed by the echarts plugins;
legend_orientation was inert).

Handlebars is intentionally skipped (fully custom HTML template).
@pull-request-size pull-request-size Bot added size/XL and removed size/M labels May 7, 2026
@msyavuz msyavuz changed the title feat(mcp): Chart formatting options feat(mcp): chart formatting options across all supported chart types May 7, 2026
@netlify
Copy link
Copy Markdown

netlify Bot commented May 7, 2026

Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit aaa7f27
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/69fce9411b695400080bb020
😎 Deploy Preview https://deploy-preview-39887--superset-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant